Shader "Optimized/Reflective/VertexLit"
{
  Properties
  {
    _Color ("Main Color", Color) = (1,1,1,1)
    _ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
    _MainTex ("Base (RGB) RefStrength (A)", 2D) = "white" {}
    _Cube ("Reflection Cubemap", Cube) = "_Skybox" {}
  }
  SubShader
  {
    Tags
    { 
      "RenderType" = "Opaque"
    }
    Pass // ind: 1, name: BASE
    {
      Name "BASE"
      Tags
      { 
        "LIGHTMODE" = "ALWAYS"
        "RenderType" = "Opaque"
      }
      // m_ProgramMask = 6
      CGPROGRAM
      //#pragma target 4.0
      
      #pragma vertex vert
      #pragma fragment frag
      
      #include "UnityCG.cginc"
      #define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
      #define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
      #define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
      
      
      #define CODE_BLOCK_VERTEX
      //uniform float3 _WorldSpaceCameraPos;
      //uniform float4x4 unity_ObjectToWorld;
      //uniform float4x4 unity_WorldToObject;
      //uniform float4x4 unity_MatrixVP;
      uniform float4 _MainTex_ST;
      uniform sampler2D _MainTex;
      uniform samplerCUBE _Cube;
      uniform float4 _ReflectColor;
      struct appdata_t
      {
          float4 vertex :POSITION;
          float3 normal :NORMAL;
          float4 texcoord :TEXCOORD0;
      };
      
      struct OUT_Data_Vert
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float3 xlv_TEXCOORD1 :TEXCOORD1;
          float4 vertex :SV_POSITION;
      };
      
      struct v2f
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float3 xlv_TEXCOORD1 :TEXCOORD1;
      };
      
      struct OUT_Data_Frag
      {
          float4 color :SV_Target0;
      };
      
      OUT_Data_Vert vert(appdata_t in_v)
      {
          OUT_Data_Vert out_v;
          float3 worldN_1;
          float3 viewDir_2;
          float2 tmpvar_3;
          float4 tmpvar_4;
          tmpvar_4.w = 1;
          tmpvar_4.xyz = in_v.vertex.xyz;
          tmpvar_3 = TRANSFORM_TEX(in_v.texcoord.xy, _MainTex);
          float3 tmpvar_5;
          tmpvar_5 = (_WorldSpaceCameraPos - mul(unity_ObjectToWorld, in_v.vertex).xyz);
          viewDir_2 = tmpvar_5;
          float3x3 tmpvar_6;
          tmpvar_6[0] = conv_mxt4x4_0(unity_WorldToObject).xyz;
          tmpvar_6[1] = conv_mxt4x4_1(unity_WorldToObject).xyz;
          tmpvar_6[2] = conv_mxt4x4_2(unity_WorldToObject).xyz;
          float3 tmpvar_7;
          tmpvar_7 = normalize(mul(in_v.normal, tmpvar_6));
          worldN_1 = tmpvar_7;
          float3 I_8;
          I_8 = (-viewDir_2);
          out_v.vertex = mul(unity_MatrixVP, mul(unity_ObjectToWorld, tmpvar_4));
          out_v.xlv_TEXCOORD0 = tmpvar_3;
          out_v.xlv_TEXCOORD1 = (I_8 - (2 * (dot(worldN_1, I_8) * worldN_1)));
          return out_v;
      }
      
      #define CODE_BLOCK_FRAGMENT
      OUT_Data_Frag frag(v2f in_f)
      {
          OUT_Data_Frag out_f;
          float4 col_1;
          col_1.xyz = ((texCUBE(_Cube, in_f.xlv_TEXCOORD1) * tex2D(_MainTex, in_f.xlv_TEXCOORD0).w) * _ReflectColor).xyz;
          col_1.w = 1;
          out_f.color = col_1;
          return out_f;
      }
      
      
      ENDCG
      
    } // end phase
    Pass // ind: 2, name: 
    {
      Tags
      { 
        "LIGHTMODE" = "Vertex"
        "RenderType" = "Opaque"
      }
      ZWrite Off
      Blend One One
      Lighting On
      // m_ProgramMask = 6
      CGPROGRAM
      //#pragma target 4.0
      
      #pragma vertex vert
      #pragma fragment frag
      
      #include "UnityCG.cginc"
      #define conv_mxt4x4_0(mat4x4) float4(mat4x4[0].x,mat4x4[1].x,mat4x4[2].x,mat4x4[3].x)
      #define conv_mxt4x4_1(mat4x4) float4(mat4x4[0].y,mat4x4[1].y,mat4x4[2].y,mat4x4[3].y)
      #define conv_mxt4x4_2(mat4x4) float4(mat4x4[0].z,mat4x4[1].z,mat4x4[2].z,mat4x4[3].z)
      #define conv_mxt4x4_3(mat4x4) float4(mat4x4[0].w,mat4x4[1].w,mat4x4[2].w,mat4x4[3].w)
      
      
      #define CODE_BLOCK_VERTEX
      //uniform float4 unity_LightColor[8];
      //uniform float4 unity_LightPosition[8];
      //uniform float4 unity_LightAtten[8];
      //uniform float4 unity_SpotDirection[8];
      //uniform float4x4 unity_ObjectToWorld;
      //uniform float4x4 unity_WorldToObject;
      //uniform float4 glstate_lightmodel_ambient;
      //uniform float4x4 unity_MatrixV;
      //uniform float4x4 unity_MatrixInvV;
      //uniform float4x4 unity_MatrixVP;
      uniform float4 _MainTex_ST;
      uniform float4 _Color;
      uniform float4 _ReflectColor;
      uniform sampler2D _MainTex;
      struct appdata_t
      {
          float4 vertex :POSITION;
          float3 normal :NORMAL;
          float4 texcoord :TEXCOORD0;
      };
      
      struct OUT_Data_Vert
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float4 xlv_COLOR0 :COLOR0;
          float4 vertex :SV_POSITION;
      };
      
      struct v2f
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float4 xlv_COLOR0 :COLOR0;
      };
      
      struct OUT_Data_Frag
      {
          float4 color :SV_Target0;
      };
      
      OUT_Data_Vert vert(appdata_t in_v)
      {
          OUT_Data_Vert out_v;
          float4x4 m_1;
          m_1 = mul(unity_WorldToObject, unity_MatrixInvV);
          float4 tmpvar_2;
          float4 tmpvar_3;
          float4 tmpvar_4;
          tmpvar_2.x = conv_mxt4x4_0(m_1).x;
          tmpvar_2.y = conv_mxt4x4_1(m_1).x;
          tmpvar_2.z = conv_mxt4x4_2(m_1).x;
          tmpvar_2.w = conv_mxt4x4_3(m_1).x;
          tmpvar_3.x = conv_mxt4x4_0(m_1).y;
          tmpvar_3.y = conv_mxt4x4_1(m_1).y;
          tmpvar_3.z = conv_mxt4x4_2(m_1).y;
          tmpvar_3.w = conv_mxt4x4_3(m_1).y;
          tmpvar_4.x = conv_mxt4x4_0(m_1).z;
          tmpvar_4.y = conv_mxt4x4_1(m_1).z;
          tmpvar_4.z = conv_mxt4x4_2(m_1).z;
          tmpvar_4.w = conv_mxt4x4_3(m_1).z;
          float4 tmpvar_5;
          tmpvar_5 = in_v.vertex;
          float4 lighting_6;
          float2 tmpvar_7;
          float4 tmpvar_8;
          tmpvar_8.w = 1;
          tmpvar_8.xyz = tmpvar_5.xyz;
          tmpvar_7 = TRANSFORM_TEX(in_v.texcoord.xy, _MainTex);
          float3 lightColor_9;
          float3 viewN_10;
          float3 viewpos_11;
          float4 tmpvar_12;
          tmpvar_12.w = 1;
          tmpvar_12.xyz = tmpvar_5.xyz;
          viewpos_11 = mul(unity_MatrixV, mul(unity_ObjectToWorld, tmpvar_12)).xyz;
          float3x3 tmpvar_13;
          tmpvar_13[0] = tmpvar_2.xyz;
          tmpvar_13[1] = tmpvar_3.xyz;
          tmpvar_13[2] = tmpvar_4.xyz;
          viewN_10 = normalize(mul(tmpvar_13, in_v.normal));
          float3 tmpvar_14;
          tmpvar_14 = (glstate_lightmodel_ambient * 2).xyz;
          lightColor_9 = tmpvar_14;
          float3 toLight_15;
          float3 tmpvar_16;
          tmpvar_16 = (unity_LightPosition[0].xyz - (viewpos_11 * unity_LightPosition[0].w));
          float tmpvar_17;
          tmpvar_17 = max(dot(tmpvar_16, tmpvar_16), 1E-06);
          toLight_15 = (tmpvar_16 * rsqrt(tmpvar_17));
          lightColor_9 = (lightColor_9 + (unity_LightColor[0].xyz * (max(0, dot(viewN_10, toLight_15)) * ((1 / (1 + (tmpvar_17 * unity_LightAtten[0].z))) * clamp(((max(0, dot(toLight_15, unity_SpotDirection[0].xyz)) - unity_LightAtten[0].x) * unity_LightAtten[0].y), 0, 1)))));
          float3 toLight_18;
          float3 tmpvar_19;
          tmpvar_19 = (unity_LightPosition[1].xyz - (viewpos_11 * unity_LightPosition[1].w));
          float tmpvar_20;
          tmpvar_20 = max(dot(tmpvar_19, tmpvar_19), 1E-06);
          toLight_18 = (tmpvar_19 * rsqrt(tmpvar_20));
          lightColor_9 = (lightColor_9 + (unity_LightColor[1].xyz * (max(0, dot(viewN_10, toLight_18)) * ((1 / (1 + (tmpvar_20 * unity_LightAtten[1].z))) * clamp(((max(0, dot(toLight_18, unity_SpotDirection[1].xyz)) - unity_LightAtten[1].x) * unity_LightAtten[1].y), 0, 1)))));
          float3 toLight_21;
          float3 tmpvar_22;
          tmpvar_22 = (unity_LightPosition[2].xyz - (viewpos_11 * unity_LightPosition[2].w));
          float tmpvar_23;
          tmpvar_23 = max(dot(tmpvar_22, tmpvar_22), 1E-06);
          toLight_21 = (tmpvar_22 * rsqrt(tmpvar_23));
          lightColor_9 = (lightColor_9 + (unity_LightColor[2].xyz * (max(0, dot(viewN_10, toLight_21)) * ((1 / (1 + (tmpvar_23 * unity_LightAtten[2].z))) * clamp(((max(0, dot(toLight_21, unity_SpotDirection[2].xyz)) - unity_LightAtten[2].x) * unity_LightAtten[2].y), 0, 1)))));
          float3 toLight_24;
          float3 tmpvar_25;
          tmpvar_25 = (unity_LightPosition[3].xyz - (viewpos_11 * unity_LightPosition[3].w));
          float tmpvar_26;
          tmpvar_26 = max(dot(tmpvar_25, tmpvar_25), 1E-06);
          toLight_24 = (tmpvar_25 * rsqrt(tmpvar_26));
          lightColor_9 = (lightColor_9 + (unity_LightColor[3].xyz * (max(0, dot(viewN_10, toLight_24)) * ((1 / (1 + (tmpvar_26 * unity_LightAtten[3].z))) * clamp(((max(0, dot(toLight_24, unity_SpotDirection[3].xyz)) - unity_LightAtten[3].x) * unity_LightAtten[3].y), 0, 1)))));
          float4 tmpvar_27;
          tmpvar_27.xyz = float3(lightColor_9);
          tmpvar_27.w = _ReflectColor.w;
          lighting_6 = tmpvar_27;
          out_v.xlv_TEXCOORD0 = tmpvar_7;
          out_v.xlv_COLOR0 = (lighting_6 * _Color);
          out_v.vertex = mul(unity_MatrixVP, mul(unity_ObjectToWorld, tmpvar_8));
          return out_v;
      }
      
      #define CODE_BLOCK_FRAGMENT
      OUT_Data_Frag frag(v2f in_f)
      {
          OUT_Data_Frag out_f;
          float4 c_1;
          c_1.xyz = (tex2D(_MainTex, in_f.xlv_TEXCOORD0).xyz * in_f.xlv_COLOR0.xyz);
          c_1.w = 1;
          out_f.color = c_1;
          return out_f;
      }
      
      
      ENDCG
      
    } // end phase
    Pass // ind: 3, name: 
    {
      Tags
      { 
        "LIGHTMODE" = "VertexLM"
        "RenderType" = "Opaque"
      }
      ZWrite Off
      Blend One One
      ColorMask RGB
      // m_ProgramMask = 6
      CGPROGRAM
      //#pragma target 4.0
      
      #pragma vertex vert
      #pragma fragment frag
      
      #include "UnityCG.cginc"
      
      
      #define CODE_BLOCK_VERTEX
      //uniform float4x4 unity_ObjectToWorld;
      //uniform float4x4 unity_MatrixVP;
      uniform float4 _MainTex_ST;
      uniform float4x4 unity_LightmapMatrix;
      uniform sampler2D unity_Lightmap;
      uniform sampler2D _MainTex;
      uniform float4 _Color;
      struct appdata_t
      {
          float4 vertex :POSITION;
          float4 texcoord :TEXCOORD0;
          float4 texcoord1 :TEXCOORD1;
      };
      
      struct OUT_Data_Vert
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float2 xlv_TEXCOORD1 :TEXCOORD1;
          float4 vertex :SV_POSITION;
      };
      
      struct v2f
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float2 xlv_TEXCOORD1 :TEXCOORD1;
      };
      
      struct OUT_Data_Frag
      {
          float4 color :SV_Target0;
      };
      
      OUT_Data_Vert vert(appdata_t in_v)
      {
          OUT_Data_Vert out_v;
          float4 tmpvar_1;
          tmpvar_1.w = 1;
          tmpvar_1.xyz = in_v.vertex.xyz;
          float4 tmpvar_2;
          tmpvar_2.zw = float2(0, 1);
          tmpvar_2.xy = in_v.texcoord1.xy;
          out_v.xlv_TEXCOORD0 = TRANSFORM_TEX(in_v.texcoord.xy, _MainTex);
          out_v.xlv_TEXCOORD1 = mul(unity_LightmapMatrix, tmpvar_2).xy;
          out_v.vertex = mul(unity_MatrixVP, mul(unity_ObjectToWorld, tmpvar_1));
          return out_v;
      }
      
      #define CODE_BLOCK_FRAGMENT
      OUT_Data_Frag frag(v2f in_f)
      {
          OUT_Data_Frag out_f;
          float4 c_1;
          float4 lm_2;
          float4 tmpvar_3;
          tmpvar_3 = (tex2D(unity_Lightmap, in_f.xlv_TEXCOORD1) * _Color);
          lm_2 = tmpvar_3;
          c_1.xyz = (tex2D(_MainTex, in_f.xlv_TEXCOORD0).xyz * (lm_2.xyz * 2));
          c_1.w = 1;
          out_f.color = c_1;
          return out_f;
      }
      
      
      ENDCG
      
    } // end phase
    Pass // ind: 4, name: 
    {
      Tags
      { 
        "LIGHTMODE" = "VertexLMRGBM"
        "RenderType" = "Opaque"
      }
      ZWrite Off
      Blend One One
      ColorMask RGB
      // m_ProgramMask = 6
      CGPROGRAM
      //#pragma target 4.0
      
      #pragma vertex vert
      #pragma fragment frag
      
      #include "UnityCG.cginc"
      
      
      #define CODE_BLOCK_VERTEX
      //uniform float4x4 unity_ObjectToWorld;
      //uniform float4x4 unity_MatrixVP;
      uniform float4 _MainTex_ST;
      uniform float4x4 unity_LightmapMatrix;
      uniform sampler2D unity_Lightmap;
      uniform sampler2D _MainTex;
      uniform float4 _Color;
      struct appdata_t
      {
          float4 vertex :POSITION;
          float4 texcoord :TEXCOORD0;
          float4 texcoord1 :TEXCOORD1;
      };
      
      struct OUT_Data_Vert
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float2 xlv_TEXCOORD1 :TEXCOORD1;
          float4 vertex :SV_POSITION;
      };
      
      struct v2f
      {
          float2 xlv_TEXCOORD0 :TEXCOORD0;
          float2 xlv_TEXCOORD1 :TEXCOORD1;
      };
      
      struct OUT_Data_Frag
      {
          float4 color :SV_Target0;
      };
      
      OUT_Data_Vert vert(appdata_t in_v)
      {
          OUT_Data_Vert out_v;
          float4 tmpvar_1;
          tmpvar_1.w = 1;
          tmpvar_1.xyz = in_v.vertex.xyz;
          float4 tmpvar_2;
          tmpvar_2.zw = float2(0, 1);
          tmpvar_2.xy = in_v.texcoord1.xy;
          out_v.xlv_TEXCOORD0 = TRANSFORM_TEX(in_v.texcoord.xy, _MainTex);
          out_v.xlv_TEXCOORD1 = mul(unity_LightmapMatrix, tmpvar_2).xy;
          out_v.vertex = mul(unity_MatrixVP, mul(unity_ObjectToWorld, tmpvar_1));
          return out_v;
      }
      
      #define CODE_BLOCK_FRAGMENT
      OUT_Data_Frag frag(v2f in_f)
      {
          OUT_Data_Frag out_f;
          float4 c_1;
          float4 lm_2;
          float4 tmpvar_3;
          tmpvar_3 = tex2D(unity_Lightmap, in_f.xlv_TEXCOORD1);
          lm_2 = tmpvar_3;
          lm_2 = (lm_2 * (lm_2.w * 2));
          lm_2 = (lm_2 * _Color);
          c_1.xyz = (tex2D(_MainTex, in_f.xlv_TEXCOORD0).xyz * (lm_2.xyz * 4));
          c_1.w = 1;
          out_f.color = c_1;
          return out_f;
      }
      
      
      ENDCG
      
    } // end phase
  }
  FallBack "Legacy Shaders/VertexLit"
}
